<template>
	<view class="chart">
		<view class="chart-pet flex-center mt-4 font-weight-900 f-size-18 mb-3">
			Milo
		</view>

		<up-tabs itemStyle="width:33.3%;height:80rpx" :list="list" lineColor='#54e4ca' lineWidth='30' :activeStyle="{
		    color: '#54e4ca',
			  fontWeight: 'bold',
		    fontSize:'28rpx'
		}" :inactiveStyle="{
		    color: '#000',
		    fontSize:'28rpx',
			  fontWeight: 'bold',
		}"></up-tabs>
		<view class="char-date flex-center mt-3 font-weight-600 f-size-12 flex-column">
			<view class="char-date-text flex-center" @click="state.show = !state.show">
				26 FEB
				<image src="../../../static/icon/more.png" mode=""></image>
				<!-- 日历组件 -->
				<view class="chart-calendar">
					<calendar v-show="state.show"></calendar>
				</view>
			</view>
			<view class="char-date-image mt-4 bor-radius-square flex-center">
				<view class="char-date-image-box bor-radius-square flex-center">
					<image src="../../../static/image/dog.png" mode="" class="bor-radius-square"></image>
					<view
						class="char-date-image-box-data flex-center flex-column f-size-10 font-weight-600 bor-radius-square">
						<text>TOTAL STEPS</text>
						<text class="f-size-18 my-2">6666</text>
						<text>80% COMPLEPLETED</text>
					</view>
				</view>



			</view>

		</view>
		<view class="chart-box  ">
			<qiun-data-charts type="column" :chartData="chartData" :opts="opts" />
		</view>
		<up-line></up-line>
		<view class="chart-data flex-between-center u-flex-wrap">
			<view class="chart-data-item flex-between-center " v-for="(item,index) in list2" :key="index">
				<image :src="item.img" mode=""></image>
				<view class="chart-data-item-text  ">
					<text class="f-size-10 font-weight-600">{{item.label}}</text>
					<text class="f-size-14 font-weight-600" style="color: #54e4ca">{{item.value}}</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script setup>
	import calendar from '@/components/calendar/calendar.vue'
	import {
		ref,
		onMounted,
		reactive
	} from 'vue'
	const state = reactive({
		show: false
	})
	const list = [{
			name: 'DAY',
		},
		{
			name: 'WEEK',
		},
		{
			name: 'MONTH',
		}
	]
	const list2 = [{
			label: 'ACTIVE HOURS',
			value: '8.8HRS',
			img: '/static/icon/v2_sghrmq.png'

		}, {
			label: 'REST HOURS',
			value: '10.8HRS',
			img: '/static/icon/v2_sgull3.png'
		},
		{
			label: 'CALORIES',
			value: '6666.6K',
			img: "/static/icon/flame.png"
		},
		{
			label: 'DISTANCE',
			value: '11.1KM',
			img: "/static/icon/if-map-pins 1@2x.png"
		}
	]
	const chartData = ref({})
	const opts = reactive({
		legend: {
			show: false
		},
		xAxis: {
			axisLine: false,
			fontSize: 10,
			fontColor: '#000',
			fontWeight: '900'
		},
		yAxis: {
			disableGrid: true,
			disabled: true
		},
		extra: {
			column: {
				width: 5,
				seriesGap: 8,

			}
		}
	})

	function getServerData() {
		//模拟从服务器获取数据时的延时
		setTimeout(() => {
			let res = {
				categories: ["12AM", "6AM", "12AM", "6AM", "12AM"],
				// legend: [ ],
				series: [{

						data: [{
							"value": 12,
							"color": "#ebebeb"
						}, 21, 38, 46, 19],
						name: "完成量",
						color: '#54e4ca',
						textSize: '0',
						textColor: '#fff'
					},
					{
						name: "完成量",
						data: [18, 27, 21, 24, 6, 28],
						textSize: '0',
					},
					{
						name: "完成量",
						data: [18, 27, 21, 24, 6, 28],
						textSize: '0',
					}
				]
			};
			chartData.value = JSON.parse(JSON.stringify(res));
			console.log(chartData.value);
		}, 500);
	}
	onMounted(() => {
		getServerData()
	})
	// const list1 = 
</script>

<style lang="scss" scoped>
	.chart {

		.char-date {
			color: grey;

			.char-date-text {
				position: relative;

				image {
					// position: ;
					// vertical-align: bottom;
					position: relative;
					top: 3rpx;
					left: 8rpx;
					width: 35rpx;
					height: 35rpx;
				}

				.chart-calendar {
					border: 1px solid #54e4ca;
					position: absolute;
					top: 40rpx;
					background-color: white;
					z-index: 999;
				}
			}

			.char-date-image {
				// border: 1px solid red;
				width: 170px;
				height: 170px;
				background-color: #55e4ca;

				.char-date-image-box {
					width: 150px;
					height: 150px;
					position: relative;
					background-color: #fff;

					image {
						position: absolute;
						width: 95%;
						height: 95%;
						z-index: 0;
					}

					.char-date-image-box-data {

						width: 100%;
						height: 100%;

						z-index: 2;
						color: #000;
						background-color: rgba(255, 255, 255, .5);
					}
				}
			}

			// align-items: center;

		}

		.chart-box {
			padding-left: 80rpx;
			padding-right: 60rpx;
			// padding: 0 80rpx;
			box-sizing: border-box;
			width: 100%;
			height: 200px;
			margin-bottom: 40rpx;
		}

		.chart-data {
			height: 300rpx;
			// border: 1px solid black;
			margin: 0 100rpx;
			margin-top: 40rpx;

			.chart-data-item {
				width: 45%;
				box-sizing: border-box;
				// border: 1px solid red;

				image {
					min-width: 70rpx;
					max-width: 70rpx;
					height: 70rpx;
					margin-right: 15rpx;
				}

				.chart-data-item-text {
					flex: 1;
					display: flex;
					flex-direction: column;
					// margin-lef30rpx;
					// margin-left: 30rpx;

					text {

						white-space: nowrap;
					}


					// text-wrap: nowrap !important;
				}
			}
		}
	}

	::v-deep .swiper {
		height: 340rpx !important;
	}
</style>